<?php

namespace App\Common\DB\Pool;

use App\Common\DB\CommonRedis;
use App\X\EHelper;
use EasySwoole\Component\Pool\AbstractPool;
use XWX\Common\H;

class PoolRedis_6380 extends AbstractPool
{
    /**
     * 请在此处返回一个数据库链接实例
     * @return CommonRedis
     */
    protected function createObject()
    {
        $redis = new CommonRedis();

        $conf = EHelper::funcGetConf("REDIS_6380");
        $connect = $redis->connect($conf['host'], $conf['port']);
        if ($connect)
        {
            if (H::funcArrayGet($conf, 'auth'))
            {
                $redis->auth($conf['auth']);
            }

            if (H::funcArrayGet($conf, 'db') != null)
            {
                $redis->select($conf['db']);
            }

            return $redis;
        }
        else
        {
            return null;
        }
    }
}